<div class="modal" ng-controller="PublishAppDefinitionPopupCtrl">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h2>{{'APP.POPUP.PUBLISH-TITLE' | translate}}</h2>
      </div>
      <div class="modal-body">

        <div ng-show="popup.error == undefined || popup.error == null">
          <p>{{'APP.POPUP.PUBLISH-DESCRIPTION' | translate:model.app}}</p>
        </div>

        <div class="alert-danger app-publish-error"
             ng-if="popup.error && popup.error.type && popup.error.type == 'conflictingProcDefKey'" role="alert">
          <span aria-hidden="true" class="glyphicon glyphicon-exclamation-sign" style="margin-right: 2px"></span>
          <span>{{'APP.POPUP.PUBLISH-ERROR-PROCDEF-KEY-CONFLICT' | translate:popup.error.data}}</span>
        </div>

        <div class="alert-danger app-publish-error"
             ng-if="popup.error && popup.error.type && popup.error.type == 'duplicateProcDefKeys'" role="alert">
          <span aria-hidden="true" class="glyphicon glyphicon-exclamation-sign" style="margin-right: 2px"></span>
          <span>{{'APP.POPUP.PUBLISH-ERROR-PROCDEF-DUPLICATE-KEYS' | translate}}</span>
          <ul>
            <li ng-repeat="entry in popup.error.data.duplicateProcessDefinitionIds">
              <span ng-repeat="(id, name) in entry">{{id}} ({{name}})</span>
            </li>
          </ul>
        </div>

        <div class="alert-warning app-publish-error"
             ng-if="popup.error && popup.error.type && popup.error.type == 'processModelAlreadyUsed'" role="alert">
          <span aria-hidden="true" class="glyphicon glyphicon-exclamation-sign" style="margin-right: 2px"></span>
          <span>{{'APP.POPUP.PUBLISH-ERROR-PROCESS-ALREADY-USED' | translate}}</span>
          <ul>
            <li ng-repeat="processName in popup.error.data.conflictingProcessModelNames track by $index">
              {{processName}} ({{'APP.POPUP.PUBLISH-ERROR-PROCESS-ALREADY-USED-APP' | translate}}
              "{{popup.error.data.conflictingAppNames[$index]}}")
            </li>
          </ul>
        </div>

      </div>
      <div class="modal-footer">
        <div class="pull-right"
             ng-if="popup.error == undefined || popup.error == null || (popup.error && popup.error.type != 'processModelAlreadyUsed')">
          <button class="btn btn-sm btn-default" ng-click="cancel()" ng-disabled="popup.loading" type="button">
            {{'GENERAL.ACTION.CANCEL' | translate}}
          </button>
          <button class="btn btn-sm btn-danger" ng-click="ok()"
                  ng-disabled="popup.loading  || (popup.error != null && popup.error != undefined)"
                  type="button">
            <span>{{'APP.ACTION.PUBLISH-CONFIRM' | translate}}</span>
          </button>
        </div>
        <div class="pull-right" ng-if="popup.error.type == 'processModelAlreadyUsed'">
          <button class="btn btn-sm btn-default" ng-click="cancel()" ng-disabled="popup.loading" type="button">
            {{'GENERAL.ACTION.CANCEL' | translate}}
          </button>
          <button class="btn btn-sm btn-success" ng-click="ok(true)" ng-disabled="popup.loading"
                  style="background-color: #5cb85c;border-color: #4cae4c;" type="button">
            <span>{{'GENERAL.ACTION.CONFIRM' | translate}}</span>
          </button>
        </div>
        <div class="loading pull-right" ng-show="popup.loading">
          <div class="l1"></div>
          <div class="l2"></div>
          <div class="l2"></div>
        </div>
      </div>
    </div>
  </div>
</div>
